<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"  
		xmlns:h="http://java.sun.com/jsf/html"  
		xmlns:f="http://java.sun.com/jsf/core"
		xmlns:ui="http://java.sun.com/jsf/facelets"
		xmlns:c="http://java.sun.com/jsp/jstl/core"
        xmlns:a4j="http://richfaces.org/a4j"
        xmlns:rich="http://richfaces.org/rich"> 
	
	<h:head>
		<!-- Charge le head à utiliser pour tout le site. -->
		<ui:include src="head.xhtml"></ui:include>
	</h:head>
	
	<h:body>
		<!-- Créé le menu principal horizontal. -->
		<header class="navbar">
			<nav class="navbar-inner">
				<div class="container">
                    <h:form class="mainMenu">
                        <h:commandLink action="#{helperNavigation.getActionUrl('index')}">
                            <h:outputText value="Accueil" class="brand"/>
                        </h:commandLink>
                    </h:form>
                    <div class="nav-collapse">
                        <ul class="nav">
                            <li>
                                <h:form class="mainMenu">
                                    <h:commandLink action="#{bookManager.loadAllBooks}">
                                        <i class="icon-book icon-white"></i>&nbsp;<h:outputText value="Bibliothèque" />
                                    </h:commandLink>
                                </h:form>
                            </li>
                            <li>
                                <h:form class="mainMenu">
                                    <h:commandLink action="cart?faces-redirect=true">
                                        <i class="icon-shopping-cart icon-white"></i>&nbsp;Panier (<c:if test="#{cartSession.invoices == null}">0</c:if><c:if test="#{cartSession.invoices != null}">#{cartSession.invoices.size()}</c:if>) 
                                    </h:commandLink>
                                </h:form>
                            </li>
                        </ul>
                    </div>
                    <ul class="nav pull-right"> 
                        <c:if test="#{!userSession.isLogged}">
                            <li>
                                <h:form class="mainMenu">
                                    <h:commandLink action="#{helperNavigation.getActionUrl('connection')}">
                                        <h:outputText value="Se connecter" />
                                    </h:commandLink>
                                </h:form>
                                <!-- Ajax test
                                    <h:outputLink value="#" id="connectionBtn">
                                        <rich:componentControl event="click" operation="show" target="connectionPopup">
                                            <a4j:param name="event" value="event" noEscape="true" />
                                        </rich:componentControl>
                                        Connexion
                                    </h:outputLink>

                                    <rich:popupPanel id="connectionPopup" autosized="true" modal="true" moveable="false" resizeable="false" followByScroll="false" onmaskclick="{rich:component('connectionPopup')}.hide()">
                                        <h:form id="formConnection">
                                            <div id="formConnectionResponseContent" class="center">
                                                <a4j:outputPanel id="formConnectionResponse">
                                                    <h:outputText value="{userManager.validateConnAjax()}" escape="false" rendered="{not empty userManager.login and not empty userManager.password}" />
                                                </a4j:outputPanel>
                                            </div>
                                            <h:panelGrid id="formConnectionPanel" columns="2" style="margin-top: 15px;">
                                                <h:outputText value="Pseudo :" />
                                                <h:inputText id="login" value="{userManager.login}" />

                                                <h:outputText value="Mot de passe :" />
                                                <h:inputSecret id="password" value="{userManager.password}" />

                                                &nbsp;
                                                <a4j:commandButton value="Connexion" render="formConnectionResponse" execute="@form" styleClass="btn btn-primary" />
                                            </h:panelGrid>
                                        </h:form>
                                    </rich:popupPanel>
                                -->
                            </li>
                            <li>
                                <h:form class="mainMenu">
                                    <h:commandLink action="#{helperNavigation.getActionUrl('registration')}">
                                        <h:outputText value="S'inscrire" />
                                    </h:commandLink>
                                </h:form>
                            </li>
                        </c:if>
                        
                        <!-- Admin access only -->
                        <c:if test="#{userSession.isLogged and userSession.isAdmin()}">
                            <li>
                                <li class="dropdown">
                                    <a href="#" class="dropdown-toggle" data-toggle="dropdown"><i class="icon-wrench icon-white"></i>&nbsp;<h:outputText value="Administration" /> <b class="caret"></b></a>
                                    <ul class="dropdown-menu">
                                        <li class="nav-header center">
                                            <h:outputText value="Livres" styleClass="label white" />
                                        </li>
                                        <li class="divider"></li>
                                        <li>
                                            <h:form class="mainMenu">
                                                <h:commandLink action="#{helperNavigation.getActionUrl('administrationBooks')}">
                                                    <i class="icon-book icon-white"></i>&nbsp;<h:outputText value="Gestion des livres" styleClass="grayLighter b" />
                                                </h:commandLink>
                                            </h:form>
                                        </li>
                                        <li>
                                            <h:form class="mainMenu">
                                                <h:commandLink action="#{helperNavigation.getActionUrl('TODO')}">
                                                    <i class="icon-wrench icon-white"></i>&nbsp;<strike><h:outputText value="Gestion des catégories des livres" styleClass="blueDark b" /></strike>
                                                </h:commandLink>
                                            </h:form>
                                        </li>
                                        <li class="divider"></li>
                                        <li class="nav-header center">
                                            <h:outputText value="Commandes" styleClass="label white" />
                                        </li>
                                        <li class="divider"></li>
                                        <li>
                                            <h:form class="mainMenu">
                                                <h:commandLink action="#{helperNavigation.getActionUrl('administrationOrders')}">
                                                    <i class="icon-briefcase icon-white"></i>&nbsp;<h:outputText value="Gestion des commandes" styleClass="grayLighter b" />
                                                </h:commandLink>
                                            </h:form>
                                        </li>
                                        <li class="divider"></li>
                                        <li class="nav-header center">
                                            <h:outputText value="Stocks" styleClass="label white" />
                                        </li>
                                        <li class="divider"></li>
                                        <li>
                                            <h:form class="mainMenu">
                                                <h:commandLink action="#{helperNavigation.getActionUrl('administrationMonitoringStocks')}">
                                                    <i class="icon-warning-sign icon-white"></i>&nbsp;<h:outputText value="Stocks critiques" styleClass="orange b" />
                                                </h:commandLink>
                                            </h:form>
                                        </li>
                                        <li>
                                            <h:form class="mainMenu">
                                                <h:commandLink action="#{helperNavigation.getActionUrl('administrationMonitoringStocks')}">
                                                    <i class="icon-eye-open icon-white"></i>&nbsp;<strike><h:outputText value="Stocks globaux" styleClass="blueDark b" /></strike>
                                                </h:commandLink>
                                            </h:form>
                                        </li>
                                        <li class="divider"></li>
                                        <li class="nav-header center">
                                            <h:outputText value="Libraires" styleClass="label white" />
                                        </li>
                                        <li class="divider"></li>
                                        <li>
                                            <h:form class="mainMenu">
                                                <h:commandLink action="#{helperNavigation.getActionUrl('administrationBooksSellers')}">
                                                    <i class="icon-user icon-white"></i>&nbsp;<strike><h:outputText value="Gestion des libraires" styleClass="blueDark b" /></strike>
                                                </h:commandLink>
                                            </h:form>
                                        </li>
                                        <li class="divider"></li>
                                        <li class="nav-header center">
                                            <h:outputText value="Configuration" styleClass="label white" />
                                            <li class="divider"></li>
                                        </li>
                                        <li>
                                            <h:form class="mainMenu">
                                                <h:commandLink action="#{helperNavigation.getActionUrl('administrationConfig')}">
                                                    <i class="icon-wrench icon-white"></i>&nbsp;<h:outputText value="Configuration générale du site" styleClass="green b" />
                                                </h:commandLink>
                                            </h:form>
                                        </li>
                                        
                                    </ul>
                                </li>
                            </li>
                        </c:if>
                        
                        <!-- Member access only -->
                        <c:if test="#{userSession.isLogged}">
                            <li>
                                <li class="dropdown">
                                    <a href="#" class="dropdown-toggle" data-toggle="dropdown"><i class="icon-bookmark icon-white"></i>&nbsp;<h:outputText value="#{userSession.login}" /> <b class="caret"></b></a>
                                    <ul class="dropdown-menu">
                                        <li class="nav-header center">
                                            <h:outputText value="Votre compte" styleClass="label white" />
                                        </li>
                                        <li class="divider"></li>
                                        <li>
                                            <h:form class="mainMenu">
                                                <h:commandLink action="#{helperNavigation.getActionUrl('profile')}">
                                                    <i class="icon-user icon-white"></i>&nbsp;<h:outputText value="Profil" styleClass="grayLighter b" />
                                                </h:commandLink>
                                            </h:form>
                                        </li>
                                        <li>
                                            <h:form class="mainMenu">
                                                <h:commandLink action="#{orderManager.setAllOrders()}">
                                                    <i class="icon-gift icon-white"></i>&nbsp;<h:outputText value="Historique des achats" styleClass="grayLighter b" />
                                                </h:commandLink>
                                            </h:form>
                                        </li>
                                        <li>
                                            <h:form class="mainMenu">
                                                <h:commandLink action="UNDEFINED-header-TODO">
                                                    <i class="icon-plus icon-white"></i>&nbsp;<strike><h:outputText value="Ajouter une carte bancaire" styleClass="blueDark b" /></strike>
                                                </h:commandLink>
                                            </h:form>
                                        </li>
                                        <li class="divider"></li>
                                        <li class="nav-header center">
                                            <h:outputText value="Commandes en cours" styleClass="label white" />
                                        </li>
                                        <li class="divider"></li>
                                        <li>
                                            <h:form class="mainMenu">
                                                <h:commandLink action="#{orderManager.setWaitingOrders()}">
                                                    <i class="icon-random icon-white"></i>&nbsp;<h:outputText value="Commandes en attente" styleClass="orange b" />
                                                </h:commandLink>
                                            </h:form>
                                        </li>
                                        <li>
                                            <h:form class="mainMenu">
                                                <h:commandLink action="#{orderManager.setShippedOrders()}">
                                                    <i class="icon-plane icon-white"></i>&nbsp;<h:outputText value="Commandes expédiées" styleClass="green b" />
                                                </h:commandLink>
                                            </h:form>
                                        </li>
                                        <li class="divider"></li>
                                        <li>
                                            <h:form class="mainMenu">
                                                <h:commandLink action="#{userManager.disconnectUser()}">
                                                    <i class="icon-off icon-white"></i>&nbsp;<h:outputText value="Déconnexion" styleClass="text-warning" />
                                                </h:commandLink>
                                            </h:form>
                                        </li>
                                    </ul>
                                </li>
                            </li>
                        </c:if>
                    </ul>
				</div>
			</nav>
		</header>
		<noscript>
			<div id="divAutoDetectJsEnable" class="alert alert-error">
				Le JavaScript n'est pas activé, veuillez l'activer pour bénéficier de toutes les fonctionnalités de ce site web.
			</div>
            <br />
		</noscript>
			<div id="globalError">
				<c:if test="#{helperMessageHtml.getNbErrors() > 0}">
					<h:outputText value="#{helperMessageHtml.displayErrorsHtml()}" escape="false" />
				</c:if>
			</div>
	</h:body>
</html>